import time
users_dicts = {}
def unique_id():
    time_stamp = int(time.time() * 1000) % 100000000
    return time_stamp
def open_an_account(name, paw, address, money, bankName='中国农业银行的昌平沙河支行'):
    account = unique_id()
    if account in users_dicts.keys():
        print('该账号已存在')
        return 2
    else:
        if len(users_dicts.keys()) >= 100:
            print('用户库已满')
            return 3
        else:
            users_dicts[account] = {'name':name,'paw':paw,'address':address,'money':money,'bankName':bankName}
            users_dicts.update(users_dicts)
            print('恭喜您开户成功')
            print('您的账号为：',account,end = ':')
            print(users_dicts[account])
            return 1
def save_money(account1,money1):
    if account1 in users_dicts.keys():
        users_dicts[account1]['money'] += money1
        print('存钱成功')
        print('您的账号为：', account1, end=':')
        print(users_dicts[account1])
    else:
        print('该账号不存在')
        return False
def draw_money(account2,paw2,money2):
    if account2 in users_dicts.keys():
        if paw2 == users_dicts[account2]['paw']:
            if users_dicts[account2]['money'] >= money2:
                users_dicts[account2]['money'] -= money2
                print('取钱成功')
                print('您的账号为：', account2, end=':')
                print(users_dicts[account2])
                return 0
            else:
                print('您的余额不足')
                return 3
        else:
            print('密码错误')
            return 2
    else:
        print('该账号不存在')
        return 1
def transfer_money(account3,account4,paw3,money3):
    if account3 in users_dicts.keys() and account4 in users_dicts.keys():
        if users_dicts[account3]['paw'] == paw3:
            if users_dicts[account3]['money'] >= money3:
                users_dicts[account3]['money'] -= money3
                users_dicts[account4]['money'] += money3
                print('转账成功')
                print('您的账号为：', account3, end=':')
                print(users_dicts[account3])
                print('对方的账号为：', account4, end=':')
                print(users_dicts[account4])
                return 0
            else:
                print('您的余额不足')
                return 3
        else:
            print('密码错误')
            return 2
    else:
        print('该账号不存在')
        return 1
def query_account(account5,paw5):
    if account5 in users_dicts.keys():
        if users_dicts[account5]['paw'] == paw5:
            print('当前您的账号为：',account5,'密码为：',paw5,'您的余额为：',users_dicts[account5]['money'],'您的开户行是：',users_dicts[account5]['bankName'])
            return 0
        else:
            print('密码错误')
            return 2
    else:
        print('该账号不存在')
        return 1

while True:
    print('*' * 20)
    print('*' + '欢迎使用银行管理系统' + '*')
    print('*' * 20)
    print('*\t 选项 \t*')
    print('*\t1.开户\t*')
    print('*\t2.存钱\t*')
    print('*\t3.取钱\t*')
    print('*\t4.转账\t*')
    print('*\t5.查询\t*')
    print('*\t6.Bye\t*')
    chice = int(input('请输入您的选择：'))
    if chice == 1:
        print('*\t1.开户\t*')
        name = input('请输入您的姓名：')
        paw = int(input('请输入您的密码：'))
        address = [input('请输入您的省份：'),input('请输入您的城市：'),input('请输入您的区县：'),input('请输入您的街道：'),input('请输入您的门牌号：')]
        money = int(input('请输入您的余额：'))
        open_an_account(name, paw, address, money)
    elif chice == 2:
        print('*\t2.存钱\t*')
        account1 = int(input('请输入您的账号：'))
        money1 = int(input('请输入您存取的金额：'))
        save_money(account1,money1)
    elif chice == 3:
        print('*\t3.取钱\t*')
        account2 = int(input('请输入您的账号：'))
        paw2 = int(input('请输入您的密码：'))
        money2 = int(input('请输入您取的金额：'))
        draw_money(account2,paw2,money2)
    elif chice == 4:
        print('*\t4.转账\t*')
        account3 = int(input('请输入转出的账号（您的账号）：'))
        account4 = int(input('请输入转入的账号（对方的账号）：'))
        paw3 = int(input('请输入您的密码：'))
        money3 = int(input('请输入您转出的金额：'))
        transfer_money(account3,account4,paw3,money3)
    elif chice == 5:
        print('*\t5.查询\t*')
        account5 = int(input('请输入您的账号：'))
        paw5 = int(input('请输入您的密码：'))
        query_account(account5,paw5)
    elif chice == 6:
        print('Bye')
        break
    else:
        print('您的输入有误，请重新输入')